from django.urls import path, re_path
from . import views
from .views.category import CategoryView
from .views.coffee import CoffeeView
from .views.fields import FieldsView
from .views.templates import TemplatesView
from .views.uploader import UploaderView
from .views.home import HomeView

urlpatterns = [
    #coffee
    path('coffee',CoffeeView.as_view(), name='coffee-list'),
    path('coffee/detail/<int:pk>', CoffeeView.detail, name='coffeeDetail'),
    path('coffee/change_status/<int:pk>', CoffeeView.change_status, name='coffeeStatus'),
    path('coffee/change_recommend/<int:pk>', CoffeeView.change_recommend, name='coffeeRecommend'),
    re_path(r'^coffee/(?P<pk>\d+)$', CoffeeView.as_view(), name='coffeeActions'),

    #category
    path('category', CategoryView.as_view(), name='category'),
    re_path(r'^category/(?P<pk>\d+)$', CategoryView.as_view(), name='categoryDetail'),

    #fields
    path('fields', FieldsView.as_view(), name='fields'),
    path('get_fields',FieldsView.get_fields_list,name='get_fields'),
    re_path(r'^fields/(?P<pk>\d+)$', FieldsView.as_view(), name='fieldsDetail'),

    #templates
    path('templates', TemplatesView.as_view(), name='templates'),
    re_path(r'^templates/(?P<pk>\d+)$', TemplatesView.as_view(), name='templatesDetail'),

    #uploader 文件上传接口
    path('uploader', UploaderView.as_view(), name='uploader'),

    #home 
    path('statistics', HomeView.get_statistics, name='statistics'),
    path('coffee_list', HomeView.get_coffee_list, name='getCoffeeList'),
    path('coffee_detail/<int:pk>', HomeView.get_coffee_detail, name='getCoffeeDetail'),
    path('coffee_view/<int:pk>', HomeView.set_coffee_view, name='setCoffeeView'),
    path('coffee_like/<int:pk>', HomeView.set_coffee_like, name='setCoffeeLike'),
]